<?php

class m_form_actions_block_front_FormAction extends f_core_Action
{
	public function execute()
	{
		$formService = m_form_services_FormService::getInstance();
       
        $formService->setStructure($this->getBlockParameter('formId'), $this->getBlockParameter('pageLang'));

        $formValues = $this->getFormValues($formService->getFormName());
        
        $formService->setContextPage($this->getContext('currentPage'))->setContextWebsite($this->getContext('currentWebsite'));

        if(count($formValues) > 0)
        {
            $formService->checkForm($formValues);

            if(!$formService->hasErrors())
            {
                $formService->executeSuccessActions($formValues);
                return;
            }
        }

        return $formService->buildHtmlForm();
	}	
}